import 'package:flutter/material.dart';
import 'package:full_display/common/qxp_style.dart';
import 'package:full_display/provide/time_provider.dart';
import 'package:full_display/unit/asset_utils/asset_utils.dart';
import 'package:full_display/unit/screen/screen_utility.dart';
import 'package:provider/provider.dart';

class CheckBoxWidget extends StatelessWidget {
  List listC = [];
  CheckBoxWidget({required this.listC, Key? key}) : super(key: key);

  late TimeProvider _timeData;
  @override
  Widget build(BuildContext context) {
    return Container(
      child: bodyWidget(listC, context),
    );
  }

  Widget bodyWidget(List list, BuildContext context) {
    return Column(
        children: List<Widget>.generate(list.length, (index) {
      return checkBoxWidgetlist(list[index], index, list, context);
    }));
  }

  Widget checkBoxWidgetlist(Map item, index, list, BuildContext context) {
    _timeData = context.watch<TimeProvider>();
    return InkWell(
      onTap: () {
        _timeData.listWeek[index]["state"] = !item["state"];
        _timeData.notifyListeners();
      },
      child: Container(
        padding: EdgeInsets.only(top: 24.0.W, bottom: 5.0.W),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Text(
              item["date"].toString(),
              textAlign: TextAlign.left,
              style: StandardTextStyle.textWhite17Style,
            ),
            Container(
              width: 20.0.W,
              height: 20.0.W,
              child: item["state"]
                  ? Image.asset(
                      height: 30.0.H,
                      width: 30.0.W,
                      AssetUtils.getAsset2Image("icon_select"),
                    )
                  : Image.asset(
                      height: 30.0.H,
                      width: 30.0.W,
                      AssetUtils.getAsset2Image("icon_noselect"),
                    ),
            ),
          ],
        ),
      ),
    );
  }
}
